package com.aspose.cells;

public class DynamicFilter {
   private int a;
   private Object b;
   private Object c;

   void a(DynamicFilter var1) {
      this.a = var1.a;
      this.c = var1.c;
      this.b = var1.b;
   }

   public int getDynamicFilterType() {
      return this.a;
   }

   public void setDynamicFilterType(int value) {
      this.a = value;
   }

   public Object getValue() {
      return this.b;
   }

   public void setValue(Object value) {
      this.b = value;
   }

   public Object getMaxValue() {
      return this.c;
   }

   public void setMaxValue(Object value) {
      this.c = value;
   }

   void a(Cells var1, int var2, int var3, int var4) {
      double var6;
      switch(this.a) {
      case 0:
      case 1:
         int var14 = 0;
         var6 = 0.0D;

         for(int var15 = var3; var15 <= var4; ++var15) {
            Cell var16 = var1.checkCell(var15, var2);
            if (var16 != null && (var16.getType() == 4 || var16.getType() == 1)) {
               var6 += var16.getDoubleValue();
               ++var14;
            }
         }

         this.b = var6 / (double)var14;
         return;
      case 4:
         DateTime var8 = DateTime.getNow().addDays(-7.0D);
         double var9 = (double)((int)CellsHelper.getDoubleFromDateTime(var8, var1.r().n().getSettings().getDate1904()));
         this.b = var9 - (double)var8.getDayOfWeek();
         this.c = var9 + 6.0D - (double)var8.getDayOfWeek();
         break;
      case 20:
         DateTime var11 = DateTime.getNow().addDays(7.0D);
         double var12 = (double)((int)CellsHelper.getDoubleFromDateTime(var11, var1.r().n().getSettings().getDate1904()));
         this.b = var12 - (double)var11.getDayOfWeek();
         this.c = var12 + 6.0D - (double)var11.getDayOfWeek();
         break;
      case 29:
         DateTime var5 = DateTime.getNow();
         var6 = (double)((int)CellsHelper.getDoubleFromDateTime(var5, var1.r().n().getSettings().getDate1904()));
         this.b = var6 - (double)var5.getDayOfWeek();
         this.c = var6 + 6.0D - (double)var5.getDayOfWeek();
      }

   }

   boolean a(Object var1, boolean var2) {
      if (this.a == 22) {
         return true;
      } else if (var1 != null && !(var1 instanceof DateTime)) {
         return false;
      } else {
         double var3 = var1 == null ? 0.0D : CellsHelper.getDoubleFromDateTime((DateTime)var1, var2);
         switch(this.a) {
         case 0:
            return var3 > (Double)this.getValue();
         case 1:
            return var3 < (Double)this.getValue();
         default:
            DateTime var5 = CellsHelper.getDateTimeFromDouble(var3, var2);
            DateTime var6 = DateTime.getNow();
            switch(this.a) {
            case 2:
               if (var5.getYear() == var6.getYear()) {
                  return var5.getMonth() + 1 == var6.getMonth();
               } else if (var5.getYear() + 1 != var6.getYear()) {
                  return false;
               } else {
                  return var5.getMonth() == 12 && var6.getMonth() == 1;
               }
            case 3:
               if (var5.getYear() == var6.getYear()) {
                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) + 1.0D == Math.ceil((double)((float)var6.getMonth() / 3.0F));
               } else {
                  if (var5.getYear() + 1 != var6.getYear()) {
                     return false;
                  }

                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) == 4.0D && Math.ceil((double)((float)var6.getMonth() / 3.0F)) == 1.0D;
               }
            case 4:
            case 20:
            case 29:
               double var7 = (double)((int)CellsHelper.getDoubleFromDateTime(var5, var2));
               return var7 >= (Double)this.b && var7 <= (Double)this.c;
            case 5:
               return var5.getYear() + 1 == var6.getYear();
            case 6:
               return var5.getMonth() == 1;
            case 7:
               return var5.getMonth() == 10;
            case 8:
               return var5.getMonth() == 11;
            case 9:
               return var5.getMonth() == 12;
            case 10:
               return var5.getMonth() == 2;
            case 11:
               return var5.getMonth() == 3;
            case 12:
               return var5.getMonth() == 4;
            case 13:
               return var5.getMonth() == 5;
            case 14:
               return var5.getMonth() == 6;
            case 15:
               return var5.getMonth() == 7;
            case 16:
               return var5.getMonth() == 8;
            case 17:
               return var5.getMonth() == 9;
            case 18:
               if (var5.getYear() == var6.getYear()) {
                  return var5.getMonth() - 1 == var6.getMonth();
               } else {
                  if (var5.getYear() - 1 != var6.getYear()) {
                     return false;
                  }

                  return var5.getMonth() == 1 && var6.getMonth() == 12;
               }
            case 19:
               if (var5.getYear() == var6.getYear()) {
                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) - 1.0D == Math.ceil((double)((float)var6.getMonth() / 3.0F));
               } else {
                  if (var5.getYear() + 1 != var6.getYear()) {
                     return false;
                  }

                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) == 1.0D && Math.ceil((double)((float)var6.getMonth() / 3.0F)) == 4.0D;
               }
            case 21:
               return var5.getYear() - 1 == var6.getYear();
            case 22:
            default:
               return true;
            case 23:
               return var5.getMonth() >= 1 && var5.getMonth() <= 3;
            case 24:
               return var5.getMonth() >= 4 && var5.getMonth() <= 6;
            case 25:
               return var5.getMonth() >= 7 && var5.getMonth() <= 9;
            case 26:
               return var5.getMonth() >= 10 && var5.getMonth() <= 20;
            case 27:
               return var5.getYear() == var6.getYear() && var5.getMonth() == var6.getMonth();
            case 28:
               if (var5.getYear() == var6.getYear()) {
                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) == Math.ceil((double)((float)var6.getMonth() / 3.0F));
               }

               return false;
            case 30:
               return var5.getYear() == var6.getYear();
            case 31:
               return var5.getYear() == var6.getYear() && var5.getMonth() == var6.getMonth() && var5.getDay() == var6.getDay();
            case 32:
               var5 = var5.addDays(-1.0D);
               return var5.getYear() == var6.getYear() && var5.getMonth() == var6.getMonth() && var5.getDay() == var6.getDay();
            case 33:
               if (var5.getYear() == var6.getYear()) {
                  if (var5.getMonth() < var6.getMonth()) {
                     return true;
                  }

                  if (var5.getMonth() == var6.getMonth()) {
                     return var5.getDay() <= var6.getDay();
                  }
               }

               return false;
            case 34:
               var5 = var5.addDays(1.0D);
               return var5.getYear() == var6.getYear() && var5.getMonth() == var6.getMonth() && var5.getDay() == var6.getDay();
            }
         }
      }
   }

   boolean a(Cell var1, boolean var2) {
      if (this.a == 22) {
         return true;
      } else if (var1 != null && var1.getType() != 1 && var1.getType() != 4) {
         return false;
      } else {
         double var3 = var1 == null ? 0.0D : var1.getDoubleValue();
         switch(this.a) {
         case 0:
            return var3 > (Double)this.getValue();
         case 1:
            return var3 < (Double)this.getValue();
         default:
            DateTime var5 = CellsHelper.getDateTimeFromDouble(var3, var2);
            DateTime var6 = DateTime.getNow();
            switch(this.a) {
            case 2:
               if (var5.getYear() == var6.getYear()) {
                  return var5.getMonth() + 1 == var6.getMonth();
               } else if (var5.getYear() + 1 != var6.getYear()) {
                  return false;
               } else {
                  return var5.getMonth() == 12 && var6.getMonth() == 1;
               }
            case 3:
               if (var5.getYear() == var6.getYear()) {
                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) + 1.0D == Math.ceil((double)((float)var6.getMonth() / 3.0F));
               } else {
                  if (var5.getYear() + 1 != var6.getYear()) {
                     return false;
                  }

                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) == 4.0D && Math.ceil((double)((float)var6.getMonth() / 3.0F)) == 1.0D;
               }
            case 4:
            case 20:
            case 29:
               double var7 = (double)((int)CellsHelper.getDoubleFromDateTime(var5, var2));
               return var7 >= (Double)this.b && var7 <= (Double)this.c;
            case 5:
               return var5.getYear() + 1 == var6.getYear();
            case 6:
               return var5.getMonth() == 1;
            case 7:
               return var5.getMonth() == 10;
            case 8:
               return var5.getMonth() == 11;
            case 9:
               return var5.getMonth() == 12;
            case 10:
               return var5.getMonth() == 2;
            case 11:
               return var5.getMonth() == 3;
            case 12:
               return var5.getMonth() == 4;
            case 13:
               return var5.getMonth() == 5;
            case 14:
               return var5.getMonth() == 6;
            case 15:
               return var5.getMonth() == 7;
            case 16:
               return var5.getMonth() == 8;
            case 17:
               return var5.getMonth() == 9;
            case 18:
               if (var5.getYear() == var6.getYear()) {
                  return var5.getMonth() - 1 == var6.getMonth();
               } else {
                  if (var5.getYear() - 1 != var6.getYear()) {
                     return false;
                  }

                  return var5.getMonth() == 1 && var6.getMonth() == 12;
               }
            case 19:
               if (var5.getYear() == var6.getYear()) {
                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) - 1.0D == Math.ceil((double)((float)var6.getMonth() / 3.0F));
               } else {
                  if (var5.getYear() + 1 != var6.getYear()) {
                     return false;
                  }

                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) == 1.0D && Math.ceil((double)((float)var6.getMonth() / 3.0F)) == 4.0D;
               }
            case 21:
               return var5.getYear() - 1 == var6.getYear();
            case 22:
            default:
               return true;
            case 23:
               return var5.getMonth() >= 1 && var5.getMonth() <= 3;
            case 24:
               return var5.getMonth() >= 4 && var5.getMonth() <= 6;
            case 25:
               return var5.getMonth() >= 7 && var5.getMonth() <= 9;
            case 26:
               return var5.getMonth() >= 10 && var5.getMonth() <= 20;
            case 27:
               return var5.getYear() == var6.getYear() && var5.getMonth() == var6.getMonth();
            case 28:
               if (var5.getYear() == var6.getYear()) {
                  return Math.ceil((double)((float)var5.getMonth() / 3.0F)) == Math.ceil((double)((float)var6.getMonth() / 3.0F));
               }

               return false;
            case 30:
               return var5.getYear() == var6.getYear();
            case 31:
               return var5.getYear() == var6.getYear() && var5.getMonth() == var6.getMonth() && var5.getDay() == var6.getDay();
            case 32:
               var5 = var5.addDays(-1.0D);
               return var5.getYear() == var6.getYear() && var5.getMonth() == var6.getMonth() && var5.getDay() == var6.getDay();
            case 33:
               if (var5.getYear() == var6.getYear()) {
                  if (var5.getMonth() < var6.getMonth()) {
                     return true;
                  }

                  if (var5.getMonth() == var6.getMonth()) {
                     return var5.getDay() <= var6.getDay();
                  }
               }

               return false;
            case 34:
               var5 = var5.addDays(1.0D);
               return var5.getYear() == var6.getYear() && var5.getMonth() == var6.getMonth() && var5.getDay() == var6.getDay();
            }
         }
      }
   }
}
